package com.hencoder.hencoderpracticedraw1.practice;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

public class Practice10HistogramView extends View {

    public Practice10HistogramView(Context context) {
        super(context);
    }

    public Practice10HistogramView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Practice10HistogramView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

//        综合练习
//        练习内容：使用各种 Canvas.drawXXX() 方法画直方图
        Paint paint = new Paint();
        paint.setColor(Color.WHITE);
        float[] points = {100, 100, 100, 300, 100, 300, 800, 300};
        canvas.drawLines(points, paint);
        paint.setColor(Color.BLUE);
        RectF rectF = new RectF();
        rectF.left = 150;
        rectF.top = 150;
        rectF.right = 200;
        rectF.bottom = 300;
        canvas.drawRect(rectF, paint);

        canvas.drawText("素质三连",155,310,paint);

//        rectF.top = 140;
//        rectF.left = 80;
//        rectF.bottom = 140;
//        rectF.right = 100;
//        canvas.drawRect(rectF, paint);
    }
}
